const router = require("koa-router")();
const { tab } = require("../mock/index");
const { getBannerSql } = require("../utils");

/**
 * @swagger
 * /banners: #接口访问路径(拼接上之前swagger.js中的host蛇者)
 *   get: #请求方式
 *     summary: 横向轮播  #接口信息
 *     description: 横向轮播 #接口描述
 *     tags: [首页] #接口分组
 *     security:     
 *       - Authorization:
 *     responses:
 *       200:
 *         description: 响应成功
 */

router.get("/banners", async (ctx) => {
  ctx.body = {
    code: 200,
    message: "获取轮播成功",
    data: await getBannerSql(),
  };
});

/**
 * @swagger
 * /home/list: #接口访问路径(拼接上之前swagger.js中的host蛇者)
 *   get: #请求方式
 *     summary: 首页选项卡 + 轮播  #接口信息
 *     description: 首页tab + 轮播 #接口描述
 *     tags: [首页] #接口分组
 *     security:     
 *       - Authorization:
 *     responses:
 *       200:
 *         description: 响应成功
 *         schema:
 *           type: object
 *           properties:
 *             code:
 *               type: integer
 *               description: 响应码
 *               default: 200
 *             message:
 *               type: string
 *               description: 消息提示
 *               default: 数据获取成功
 *             data:
 *               type: array
 *               items:
 *                 type: object
 *                 properties:
 *                   title:
 *                     type: string
 *                     default: 一级标题
 *                   children:
 *                     type: array
 *                     items:
 *                       type: object
 *                       properties:
 *                         title:
 *                           type: string
 *                           default: 二级标题
 *                         images:
 *                           type: array
 *                           items:
 *                             type: object
 *                             properties:
 *                               url:
 *                                 type: string
 *                                 default: 图片路径
 */
router.get("/home/list", (ctx) => {
  ctx.body = {
    code: 200,
    data: tab,
    message: "数据获取成功",
  };
});

module.exports = router;
